home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / gxfrac.h < prev    next >
C/C++ Source or Header  |  1993-05-13  |  2KB  |  44 lines

  1. /* Copyright (C) 1992 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gxfrac.h */
  20. /* Fraction representation for Ghostscript */
  21.  
  22. #ifndef gxfrac_INCLUDED
  23. #  define gxfrac_INCLUDED
  24.  
  25. /* Represent a fraction in [0.0..1.0]. */
  26. /* Note that the 1.0 endpoint is included. */
  27. /* Since undercolor removal requires a signed frac, */
  28. /* we limit fracs to 15 bits rather than 16. */
  29. typedef short frac;
  30. typedef short signed_frac;
  31. #define frac_bits (arch_sizeof_short * 8 - 1)
  32. #define frac_0 ((frac)0)
  33. #define frac_1 ((frac)0x7fff)
  34. #define frac_1_long ((long)frac_1)
  35. #define frac_1_float ((float)frac_1)
  36. /* Conversion between fracs and floats */
  37. #define frac2float(fr) ((fr) / frac_1_float)
  38. #define float2frac(fl) ((frac)(((fl) + 0.5 / frac_1_float) * frac_1_float))
  39. /* Conversion between fracs and bytes representing fractions */
  40. #define frac2byte(fr) ((byte)((fr) >> (frac_bits - 8)))
  41. #define byte2frac(b) ((frac)(((uint)(b) << (frac_bits - 8)) + ((b) >> (16 - frac_bits))))
  42.  
  43. #endif                    /* gxfrac_INCLUDED */
  44.